<template>
  <div id="deliver">
    <Sidebar></Sidebar>
    <div style="height: 900px; width: 1500px; margin-left: 10%; margin-top: 5%">
      <el-container style="height: 100vh; border: 1px">
        <el-aside width="300px">
          <PerSidebar></PerSidebar>
        </el-aside>
        <el-main>
          <!-- 已投递 -->
          <el-table :data="tableData" style="margin-top: 20px">
            <el-table-column width="1150">
              <template slot-scope="scope">
                <div @click="jobdescribe(scope.row)">
                  <el-descriptions style="margin-bottom: 0; font-size: large">
                    <el-descriptions-item label="职位名称">
                      {{ scope.row.pname }}
                    </el-descriptions-item>
                    <el-descriptions-item label="公司">
                      {{ scope.row.cname }}
                    </el-descriptions-item>
                    <el-descriptions-item label="薪资">
                      {{ scope.row.salary }}
                    </el-descriptions-item>
                    <el-descriptions-item label="热度">
                      <el-tag size="small">
                        {{ scope.row.hot }}
                      </el-tag>
                    </el-descriptions-item>
                  </el-descriptions>
                </div>
              </template>
            </el-table-column>
          </el-table>
          <!-- 退出登录 -->
          <div>
            <el-button
              type="text"
              style="
                color: black;
                font-size: x-large;
                float: right;
                margin-top: 180px;
              "
              @click="Loginout"
              >退出登录</el-button
            >
          </div>
        </el-main>
      </el-container>
    </div>
  </div>
</template>
    <script>
import axios from "axios";
import Sidebar from "@/components/SeekerSidebar.vue";
import PerSidebar from "@/components/PersonSidebar.vue";
import { EventBus } from '@/util/event-bus.js';
export default {
  components: {
    Sidebar,
    PerSidebar,
  },
  created() {
    this.getapply();
  },
  data() {
    return {
      SeekerUserData: JSON.parse(sessionStorage.getItem("SeekerUser")),
      tableData: [],
    };
  },
  methods: {
    closeWebSocket() {
      EventBus.$emit('close-websocket-seeker');
    },
    getapply() {
      let data = new FormData();
      data.append("susername", this.SeekerUserData.susername);
      axios
        .post("http://localhost:8080/hqdx/seeker/showApplyComPosition", data)
        .then((response) => {
          this.tableData = response.data.data.items;
        })
        .catch((error) => {
          console.log(error);
        });
    },
    jobdescribe(row) {
      this.$router.push({
        name: "Posdescribe",
        params: { ElemSeekerPos: row },
      });
    },
    Loginout() {
      this.closeWebSocket();
      let data = new FormData();
      data.append("susername", this.SeekerUserData.susername);
      axios
        .post("http://localhost:8080/hqdx/seeker/loginout", data)
        .then((response) => {})
        .catch((error) => {
          console.log(error);
        });
      this.$router.push("/login");
      sessionStorage.setItem("LoginSeekerState", JSON.stringify(false)); //退出登录，状态记录
    },
  },
};
</script>
    <style scoped>
#deliver {
  background: linear-gradient(to right, #ffffff, #e0f7fa);
}
.el-aside {
  background-color: white;
  text-align: center;
}

.el-main {
  background: linear-gradient(to right, #ffffff, #e0f7fa);
  color: #333;
  text-align: center;
}
</style>